package com.lh.pattern.proxy.dynamicproxy;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;

public class Test {
	public static void main(String[] args) {
		HelloWorld hw = new HelloWorldImpl(); 
		InvocationHandler handler = new HelloWorldHandler(hw); 
		HelloWorld proxy = (HelloWorld) Proxy.newProxyInstance(
				hw.getClass().getClassLoader(),
				hw.getClass().getInterfaces(),
				handler);
		proxy.sayHelloWorld();
		String [] c = new String[]{"111","222","333"};
		Constructor<Integer> cc = null;
		try {
			 cc =Integer.class.getConstructor(new Class[]{String.class});
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		}
//		c[0].
		for(String s:c){
			System.out.println(s);
		}
		Integer d = null;
		try {
			d=cc.newInstance(new Object[]{"789"});
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		System.out.println(d);
	}
}
